package learn.rxjava.train;

import io.reactivex.rxjava3.annotations.NonNull;
import io.reactivex.rxjava3.core.Observable;
import io.reactivex.rxjava3.core.ObservableEmitter;
import io.reactivex.rxjava3.core.ObservableOnSubscribe;
import io.reactivex.rxjava3.core.Observer;
import io.reactivex.rxjava3.disposables.Disposable;

public class SubscribeDemo1 {
    public static void main(String[] args) {
        SubscribeDemo1 demo1 = new SubscribeDemo1();
        demo1.test1();
    }

    Observer<Object> observer = new Observer<Object>() {

        @Override
        public void onSubscribe(@NonNull Disposable d) {

        }

        @Override
        public void onNext(Object o) {
            System.out.println("onNext" + o);
        }

        @Override
        public void onError(@NonNull Throwable e) {

        }

        @Override
        public void onComplete() {

        }
    };

    public void test1() {
        Observable.create(emitter -> {
            emitter.onNext("123213");
            emitter.onComplete();
        }).subscribe(observer);
    }
}
